* Run on Stata 13 for Mac (OS 9)
* June 3, 2016

***********************************************
* MAIN RESULTS: TABLES 1 AND 2
***********************************************


*** Set Path 
* cd "..."

use "industry_country.dta", clear
	
	
******************************************
* TABLE 1
******************************************

* model 1. Baseline
reg wtaxcomp region lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfc##c.obsolete##c.tariff ln_tot_pop free_media,  vce(cluster country)
*outreg2 using ".../main_results_rr.xls", dec(3) alpha(.01, .05, .1) replace

* Model 2. Mining
reg wtaxcomp region lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfc##c.obsolete##c.tariff ln_tot_pop free_media mining ,  vce(cluster country)
*outreg2 using ".../main_results_rr.xls", dec(3) alpha(.01, .05, .1) append

* Model 3. Sectors
reg wtaxcomp region lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfc##c.obsolete##c.tariff ln_tot_pop free_media i.sector,  vce(cluster country)
*outreg2 using ".../main_results_rr.xls", dec(3) alpha(.01, .05, .1) append

* Model 4. Outliers Dropped
reg wtaxcomp region lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfc##c.obsolete##c.tariff i.sector ln_tot_pop free_media if industry_id!=315 & industry_id!=371,  vce(cluster country)
*outreg2 using ".../main_results_rr.xls", dec(3) alpha(.01, .05, .1) append

* Model 5. Country Fixed Effect
reg wtaxcomp region lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfc##c.obsolete##c.tariff i.sector ln_tot_pop free_media i.idc,  vce(cluster country)
*outreg2 using ".../main_results_rr.xls", dec(3) alpha(.01, .05, .1) append

* Model 6. HLM - Run on R. 


******************************************
* TABLE 2
******************************************


* Model 1. Unweighted Tax Compliance
reg uwtaxcomp region lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfc##c.obsolete##c.tariff ln_tot_pop free_media i.sector,  vce(cluster country)
*outreg2 using ".../robustness.xls", dec(3) alpha(.01, .05, .1) replace

* Model 2. HLM - Run on R. 

* Model 3. Total tax to GDP [Reverse and normalize TAX to GDP] 
gen lowfs_new = 100 - taxy
gen lowfs_new_scaled = lowfs_new/100

reg wtaxcomp region lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfs_new_scaled##c.obsolete##c.tariff ln_tot_pop free_media i.sector, vce(cluster country)
*outreg2 using ".../robustness.xls", dec(3) alpha(.01, .05, .1) append

* Modelo 4. VAT [Reverse and normalize VAT to GDP] 
gen lowfs_new_2 = 100 - vaty
gen lowfs_new_scaled_2 = lowfs_new_2/100

reg wtaxcomp region lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfs_new_scaled_2##c.obsolete##c.tariff ln_tot_pop free_media i.sector, vce(cluster country)
*outreg2 using ".../robustness.xls", dec(3) alpha(.01, .05, .1) append

* Model 5. Tariffs by Others
bysort digit2 : gen case = _n
bysort digit2: egen total = max(case)
order tariff, after(total)
bysort digit2: egen total_tariff = total(tariff)
gen total_tariff_without_case = total_tariff - tariff
gen total_without_case = total - 1 
gen mean_tariff_foreign_industry = total_tariff_without_case/total_without_case

reg wtaxcomp region lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfc##c.obsolete##c.mean_tariff_foreign_industry i.sector ln_tot_pop free_media,  vce(cluster country)
*outreg2 using ".../robustness.xls", dec(3) alpha(.01, .05, .1) append

* Model 6. Democracies
reg wtaxcomp region i.sector  lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfc##c.obsolete##c.tariff ln_tot_pop free_media if boix_democracy == 1,  vce(cluster country)
*outreg2 using ".../robustness.xls", dec(3) alpha(.01, .05, .1) append

* Model 7. Non-Democracies
reg wtaxcomp region i.sector lnavgexp avgcompetitors lnavgage lntotlabor gov_owner_share c.lowfc##c.obsolete##c.tariff ln_tot_pop free_media if boix_democracy == 0,  vce(cluster country)
*outreg2 using ".../robustness.xls", dec(3) alpha(.01, .05, .1) append

